<?php
	function smarty_function_select_all_products_with_group($params, &$smarty){
		global $setupdata, $mysqlclass;
		$result = array();
		
		$q = "
			SELECT DISTINCT  `t1`.`id` , `t1`.`name` , `t2`.`name` AS `parent` 
			FROM `".$setupdata['table_prefix']."catalog` `t1`, `".$setupdata['table_prefix']."catalog` `t2`
			WHERE `t1`.`type` = 'catalog' AND `t1`.`parent` = `t2`.`id` AND `t1`.`hide`=1 AND `t2`.`hide`=1
			ORDER BY `t1`.`parent`
		";
		$sql = $mysqlclass->mysql_my_query($q, __LINE__, __FILE__);
		while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) {
			$result[$row['parent']][$row['id']] = $row['name'];
		}
		
		if (empty($params['assign'])) return $result;
	    else $smarty->assign($params['assign'], $result);
	}
?>
